package fr.cephb.joperon.core.bio;



/**
 * An enum for the chromosomes, follow Mario Foglio's indices 
 * @author lindenb
 *
 */
public enum Chromosome
	{
	Chr1
		{	
		@Override
		public int getId(){ return 1;}
		},
	Chr2
		{	
		@Override
		public int getId(){ return 2;}
		},
	Chr3
		{	
		@Override
		public int getId(){ return 3;}
		},
	Chr4
		{	
		@Override
		public int getId(){ return 4;}
		},
	Chr5
		{	
		@Override
		public int getId(){ return 5;}
		},
	Chr6
		{	
		@Override
		public int getId(){ return 6;}
		},
	Chr7
		{	
		@Override
		public int getId(){ return 7;}
		},
	Chr8
		{	
		@Override
		public int getId(){ return 8;}
		},
	Chr9
		{	
		@Override
		public int getId(){ return 9;}
		},
	Chr10
		{	
		@Override
		public int getId(){ return 10;}
		},
	Chr11
		{	
		@Override
		public int getId(){ return 11;}
		},
	Chr12
		{	
		@Override
		public int getId(){ return 12;}
		},
	Chr13
		{	
		@Override
		public int getId(){ return 13;}
		},
	Chr14
		{	
		@Override
		public int getId(){ return 14;}
		},
	Chr15
		{	
		@Override
		public int getId(){ return 15;}
		},
	Chr16
		{	
		@Override
		public int getId(){ return 16;}
		},
	Chr17
		{	
		@Override
		public int getId(){ return 17;}
		},
	Chr18
		{	
		@Override
		public int getId(){ return 18;}
		},
	Chr19
		{	
		@Override
		public int getId(){ return 19;}
		},
	Chr20
		{	
		@Override
		public int getId(){ return 20;}
		},
	Chr21
		{	
		@Override
		public int getId(){ return 21;}
		},
	Chr22
		{	
		@Override
		public int getId(){ return 22;}
		},
	ChrW
		{	
		@Override
		public int getId(){ return 93;}
		},
	ChrX
		{	
		@Override
		public int getId(){ return 94;}
		},
	ChrY
		{	
		@Override
		public int getId(){ return 95;}
		},
	ChrZ
		{	
		@Override
		public int getId(){ return 96;}
		},
	ChrMT
		{	
		@Override
		public int getId(){ return 97;}
		},
	ChrCL
		{	
		@Override
		public int getId(){ return 98;}
		},
	ChrUndefined
		{	
		@Override
		public int getId(){ return -1;}
		@Override
		public String getOperonName() {
			return "U";
			}
		
		}
		;

	public abstract int getId();
	/** get name in Operon for the FID */
	public String getOperonName()
		{
		return name().substring(3);
		}
	
	
/** return a chromosome from a String
 * @return the chromosome or ChrUndefined if not found */
public static Chromosome getByName(String name)
	{
	if(name==null) return ChrUndefined;
	for(Chromosome c: values())
		{
		if(c.getOperonName().equalsIgnoreCase(name) || c.name().equalsIgnoreCase(name)) return c;
		}
	return ChrUndefined;
	}

/** return a chromosome from its id
 * @return the chromosome or ChrUndefined if not found */
public static Chromosome getById(int id)
	{
	switch(id)
		{
		case 1: return Chr1;
		case 2: return Chr2;
		case 3: return Chr3;
		case 4: return Chr4;
		case 5: return Chr5;
		case 6: return Chr6;
		case 7: return Chr7;
		case 8: return Chr8;
		case 9: return Chr9;
	
		case 10: return Chr10;
		case 11: return Chr11;
		case 12: return Chr12;
		case 13: return Chr13;
		case 14: return Chr14;
		case 15: return Chr15;
		case 16: return Chr16;
		case 17: return Chr17;
		case 18: return Chr18;
		case 19: return Chr19;
		case 20: return Chr20;
		case 21: return Chr21;
		case 22: return Chr22;
		
		case 93: return ChrW;
		
		case 94: return ChrX;
		case 95: return ChrY;
	
		case 96: return ChrZ;
		case 97: return ChrMT;
		case 98: return ChrCL;
		default:return ChrUndefined;
		}
	}

public static void main(String[] args)
	{
	for(Chromosome chr:values())
		{
		System.out.println(chr);
		}
	}
}
